#include "qcalendardialog.h"
#include "ui_qcalendardialog.h"
#include <QDesktopWidget>

QCalendarDialog::QCalendarDialog(QWidget *parent) :
    QDialog(parent)
    , ui(new Ui::QCalendarDialog)
    , state(Cancel)
{
    ui->setupUi(this);
    setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);

#ifdef ANDROID
    //获取设备屏幕大小
    QDesktopWidget* desktopWidget = QApplication::desktop();
    if (desktopWidget)
    {
        QRect screenRect = desktopWidget->screenGeometry();
        int nActScreenX = screenRect.width();
        int nActScreenY = screenRect.height();
        resize(nActScreenX, nActScreenY / 2);
    }
#endif
}

QCalendarDialog::~QCalendarDialog()
{
    delete ui;
}

QDate QCalendarDialog::selectedDate() const
{
    return ui->CalendarWidget->selectedDate();
}

void QCalendarDialog::on_OkButton_clicked()
{
    state = Ok;
    close();
}

void QCalendarDialog::on_CancelButton_clicked()
{
    state = Cancel;
    close();
}
